<?php    
// Flex ���ݵ��ļ��? name ����Ϊ Filedata  
	define('SERVER_NAME','localhost');
	define('MYSQL_USERNAME','root');
	define('MYSQL_PASSWORD','');
	define('MYSQL_TABLENAME','albumshare2009');
	define('SERVER_PORT','');
	
	$_db = null;
 	$sql;
 	$result;
 	try
	{ 	
		$this->_db = mysql_connect(SERVER_NAME,MYSQL_USERNAME,MYSQL_PASSWORD);
		mysql_select_db(MYSQL_TABLENAME,$this->_db);
		mysql_query("SET NAMES 'utf8'");
	}catch(Excption $exc)
	{
		return $exc;
	}
	
	$fileUploader = $_REQUEST["email"];
	
	if($fileUploader)
	{
		$email = strtolower(trim($targetID));
 		try
 		{
 			$this->sql = "SELECT students.email FROM students WHERE email='$email'";
 			$this->result = mysql_query($this->sql,$this->_db);
 			$numRows = mysql_num_rows($this->result);
	 		if($numRows>=1)
	 		{
	 			$fileCatagory = $_REQUEST["ano"];
				$fileName = $_FILES["Filedata"]["name"]; 
				$fileNameNew = strpbrk($fileName, '.'); //������Ƭ��
				$dest=date("Ymd")."_".date("ahis").$fileNameNew;//�����ļ���Ϊ���ڼ����ļ���׺������ظ���  
				$file = $_FILES["Filedata"]["tmp_name"];    
				$path = "uploadFiles/";
				if (move_uploaded_file($file, $path.$fileCatagory.$dest)){	
					return $dest;
				}else{    
					return "failure";//�ϴ�ʧ�ܣ�    
				}  
	 		}else
	 		{
	 			return trigger_error("Your wanna upload but your email not exist in our database!");
	 		}
 		}catch(Exception $exc)
 		{
 			return $exc;
 		}
	}
?>  